package com.youxin.busfoundation.utils.web;
/**
 * Cookie工具类
 * @author yingde.cao
 *
 */

import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;

import com.youxin.foundation.utils.ArrayUtils;

public class CookieUtils {
	/**
	 * 查找Cookie
	 * @param name
	 * @param request
	 * @return
	 */
	public static Cookie getCookie(String name,HttpServletRequest request)
	{
        Cookie[] cookies = request.getCookies();  
        if(ArrayUtils.isEmpty(cookies)){
        	return null;
        }
        Cookie cookie=null;
        for(Cookie item:cookies)
        {
        	if(item.getName().equals(name))
        	{
        		cookie=item;
        	}
        }
        return cookie;
	}
}
